<?php


include('conn.php');
$state = 2;

$likenum = $_POST["likenum"];
$likenum = implode(",", $likenum);//数组转字符串
if(strlen($likenum)>0){
    if(substr( $likenum, 0,1 )==","){
        $likenum = substr( $likenum, 1 );
    }
}

$unlikenum = $_POST["unlikenum"];
$unlikenum = implode(",", $unlikenum);//数组转字符串
if(strlen($unlikenum)>0){
    if(substr( $unlikenum, 0,1 )==","){
        $unlikenum = substr( $unlikenum, 1 );
    }
}


$sql1 = "UPDATE images SET `love` = `love`+1 WHERE id in (".$likenum.")" ;
$sql2 = "UPDATE images SET `love` = `love`-1 WHERE id in (".$unlikenum.")" ;

$query = mysql_query($sql1);
$rows1 = mysql_affected_rows();
$query2 = mysql_query($sql2);  
$rows2 = mysql_affected_rows();

if($rows1>0||$rows2>0){
$state =1;  
}

$arrstate = array();

$arrstate["state"]=$state;

echo json_encode($arrstate);



?>